function hist = histc2d( v1, v2, T1, T2 )
    l1 = T1*2+1;
    l2 = T2*2+1;
    hist = zeros(l1, l2);
    for i=1:length(v1)
        val1 = v1(i);
        if val1 > T1
            val1 = T1;
        end
        if val1 < -T1
            val1 = -T1;
        end
        val2 = v2(i);
        if val2 > T2
            val2 = T2;
        end
        if val2 < -T2
            val2 = -T2;
        end
        hist(val1+T1+1,val2+T2+1) = hist(val1+T1+1,val2+T2+1)+1;
    end    
end

